package soundwave.com.demo.list;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.activity.Login;
import soundwave.com.demo.adpater.TakeoutfoodContent_adapert;
import soundwave.com.demo.entry.LoginSingle;
import soundwave.com.demo.test.TakeoutfoodContent_test;

/**
 * Created by xu on 2017/4/1.
 */

public class TakeoutfoodGrid extends Activity {
    private Context context=this;
    private GridView takeoufood;
    private TextView back;
    private TextView shoppingcart;
    private TextView shoppingnumber;
    private ImageView image;
    private EditText takeoutfood_text;
    private GridView takeoutfood_content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.takeoutfood);
        initView();
        onclik();

        takeoufood = (GridView) findViewById(R.id.takeoutfood_content);
        ArrayList<TakeoutfoodContent_test> takeoutfood = new ArrayList<>();
        TakeoutfoodContent_test takeoutfoodContent_test = new TakeoutfoodContent_test();


        takeoutfood.add(takeoutfoodContent_test);

        TakeoutfoodContent_adapert adapert = new TakeoutfoodContent_adapert(this, R.layout.takeoutfood_layout, takeoutfood);
        takeoufood.setAdapter(adapert);
        adapert.notifyDataSetChanged();

    }

    private void initView() {
        back = (TextView) findViewById(R.id.back);
        shoppingcart = (TextView) findViewById(R.id.shoppingcart);

        shoppingnumber = (TextView) findViewById(R.id.shoppingnumber);

        image = (ImageView) findViewById(R.id.image);

        takeoutfood_text = (EditText) findViewById(R.id.takeoutfood_text);

        takeoutfood_content = (GridView) findViewById(R.id.takeoutfood_content);

    }

    private void onclik() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        shoppingcart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final LoginSingle loginSingle=LoginSingle.getInstance();
                if (loginSingle.isLogin()){
                     startActivity(new Intent(context,ShoppingList.class));
                }else {
                    startActivity(new Intent(context, Login.class));
                }
            }
        });

    }


}
